﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "数据字典");
		
		rs_dict = queryNew("code_id");
		
		name = "";
		
		sql = "SELECT code_id,field_id,code,name from i_code_info where field_id = :fieldId order by length(name), name";
			
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="fieldId", value=event.getArg("dict","4"), cfsqltype="cf_sql_integer" );
			    
		rs_dict = queryObj.execute( sql=sql ).getResult();
		
		if( event.getArg("dict","4") eq "4" ){
		
			/*学生类型*/			
			name = "学生类型";
			
		}else if( event.getArg("dict","4") eq "2" ){
			/*国家字典*/
			name = "国家";
			
		}else if( event.getArg("dict","4") eq "3" ){
			/*经费来源*/
			name = "经费来源";
			
		}
		rs_dictEdit = queryNew("");
		
		if( event.getArg("edit") eq "1" ){
			
			sql = "SELECT code_id,field_id,code,name from i_code_info where code_id = :codeId order by length(name), name";
			
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="codeId", value=event.getArg("codeId","4"), cfsqltype="cf_sql_integer" );
				    
			rs_dictEdit = queryObj.execute( sql=sql ).getResult();
		
		}
	
		passArgs = structNew();
		
		structInsert(passArgs,"dict",event.getArg("dict","4"));
		
		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">返回上级</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 link"></i>数据字典
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	
	<ul class="dataSync">
		<li>
			<div class="clearfix">
				<form id="formSync" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('dictionary')#</cfoutput>">
					<div class="label">
						<span class="req">*</span><b>数据类型</b>
                              <select name="dict" id="dict" class="inlinePart">
                              	<option value="4" <cfif event.getArg("dict","4") eq 4> selected="selected"</cfif> >学生类型</option>
                                   <option value="2" <cfif event.getArg("dict","4") eq 2> selected="selected"</cfif>>国家</option>
                                   <option value="3" <cfif event.getArg("dict","4") eq 3> selected="selected"</cfif>>经费来源</option>
                              </select>
					</div>
				</form>
                    <div class="UItab">
					<div class="tabLables">
                         <cfif event.getArg("dict","4") eq 4>
						<span <cfif event.getArg("edit") neq "1">class="active"</cfif> id="labStuType" tabTarget="dict">学生类型</span>
                         <cfelseif event.getArg("dict","4") eq 2>
						<span <cfif event.getArg("edit") neq "1">class="active"</cfif> id="labCountry" tabTarget="dict">国家</span>
                         <cfelseif event.getArg("dict","4") eq 3>   
						<span <cfif event.getArg("edit") neq "1">class="active"</cfif> id="labFunds" tabTarget="dict">经费来源</span>
                         </cfif>
                         	<span id="labAdd" tabTarget="add">添加<cfoutput>#name#</cfoutput></span>
                          <cfif event.getArg("edit") eq "1">
                          	<span class="active" id="labEdit" tabTarget="edit">修改<cfoutput>#name#</cfoutput></span>
                          </cfif>
					</div>
				</div>
                    
                    <script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
                    
                    <script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						
						$("#dict").change(function() {
							
							$("#formSync").submit();
							
						});
						
					});
				
					// -->
					//]]>				
				</script>
                    
                    <div id="dict" class="tabContent">
				
					 <cfset row = 0 />
                          <table class="UIEditable">
                               <thead>
                                    <tr>
                                         <td width="38"></td>
                                         <td width="40">字典编号</td>
                                         <td width="330"><cfoutput>#name#</cfoutput></td>                                         
                                         <td width="18">修改</td>
                                         <td width="18">删除</td>
                                    </tr>
                               </thead>
                               <tbody>
                            <cfloop query="rs_dict">
                                         
                                         <cfset row++ />
                                         <cfset structInsert(passArgs, "codeId", rs_dict.code_id, true) />
                                         <cfset structInsert(passArgs, "edit", "1", true) />
                                         
                                         <tr class="editRows">
                                              <td class="index"><cfoutput>#row#</cfoutput></td>
                                              <td><cfoutput>#rs_dict.code_id#</cfoutput></td>
                                              <td><cfoutput>#rs_dict.name#</cfoutput></td>
                                              <td><a href="<cfoutput>#buildURL('dictionary', passArgs)#</cfoutput>" title="修改" class="stat struct"></a></td>
                                               <cfset structDelete(passArgs, "edit") />
                                              <td><a href="<cfoutput>#buildURL('dictionaryDelete', passArgs)#</cfoutput>" onclick="return checked();" title="删除" class="stat delete"></a></td>
                                         </tr>
                                    </cfloop>
                               </tbody>
                          </table>
                          
				</div>
                    
                    <div id="add" class="tabContent">
				
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('dictionaryAdd')#</cfoutput>">
                         
                         	<input name="dict" id="dict" type="hidden" value="<cfoutput>#rs_dict.field_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>添加<cfoutput>#name#</cfoutput></b>
							<input name="dictName" id="dictName" type="text" class="typeTextShort" verification="required" maxlength="30" value="" />
						</div>
						
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
						</div>
						
					</form>
                          
				</div>
                    
                    <cfif rs_dictEdit.recordCount >
                         <div id="edit" class="tabContent">
                         
                              <form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('dictionaryUpdate')#</cfoutput>">
                              
                                   <input name="dict" id="dict" type="hidden" value="<cfoutput>#rs_dictEdit.field_id#</cfoutput>" />
                                   <input name="codeId" id="codeId" type="hidden" value="<cfoutput>#rs_dictEdit.code_id#</cfoutput>" />
                                   
                                   <div class="label">
                                        <span class="req">*</span><b>修改<cfoutput>#name#</cfoutput></b>
                                        <input name="dictName" id="dictName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#rs_dictEdit.name#</cfoutput>" />
                                   </div>
                                   
                                   
                                   <hr/>
                                   
                                   <div class="lable">
                                        <input class="button" type="submit" value="提交" />
                                   </div>
                                   
                              </form>
                               
                         </div>
                    </cfif>
                    
                    <script language="javascript" type="text/javascript">
				
                    	function checked(){
						var msg = "您真的确定要删除吗？\n\n请确认！"; 
						if (confirm(msg)==true){ 
							return true; 
						}else{ 
							return false; 
						} 
					}
                    
                    </script>
                    
			</div>
		</li>
	</ul>
	
	
	
</div>